package com.jxc.service.impl;

import com.jxc.mapper.RoleMapper;
import com.jxc.pojo.Role;
import com.jxc.pojo.RoleExample;
import com.jxc.service.RoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleMapper roleMapper;
    @Override
    public List<Role> findRolesById(Integer userId) {
        return roleMapper.findRolesById(userId);
    }

    @Override
    public List<Role> selectByExample(String name) {
        RoleExample roleExample = new RoleExample();
        if(name != null && !"".equals(name)) {
            roleExample.createCriteria().andNameLike(name);
        }else{
            name = "";
        }
        List<Role> roles = roleMapper.selectByExample(roleExample);
        return roles;
    }

    @Override
    public int insert(Role record) {
        return roleMapper.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return roleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(Role record) {
        return roleMapper.updateByPrimaryKey(record);
    }

    @Override
    public Role findRoleName(String name) {
        return roleMapper.findRoleName(name);
    }

}
